package com.aaa.controller;

import com.aaa.dao.BookDaos;
import com.aaa.dao.BookMapper;
import com.sun.org.apache.bcel.internal.generic.NEW;
import com.wsc.entity.Book;
import com.wsc.entity.Inventory;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
@RequestMapping("book")
public class BookController {
    @Resource
    BookMapper bookMapper;
    @Resource
    BookDaos bookDaos;
    @RequestMapping("select")
    public Object select(){
        return bookDaos.select1();
    }
    @RequestMapping("select2")
    public Integer select2(Integer book){
        System.out.println("这是book"+book);
        Inventory inventory = new Inventory();
        inventory.setBook(book);
        System.out.println(bookDaos.select2(book));
        return bookDaos.select2(book);
    }
    @RequestMapping("insert")
    public Integer insert(Book book){
        return bookMapper.insert(book);
    }
    @RequestMapping("delete")
    public Integer delete(Integer id){
        return bookMapper.deleteById(id);
    }
    @RequestMapping("update")
    public Integer update(Book book){
        return bookMapper.updateById(book);
    }
}
